function changeAText() {
    // body...
    var x = document.getElementById('goldCard')
    x.innerHTML = "银卡"
}

function changeATextColor() {
    // body...
    var element = document.getElementById('goldCard');

    element.style.color = 'white';
}

function outputNodeNameByTag() {
    // body...
    var tagNode = document.getElementsByTagName("p");
    alert(tagNode[0].nodeName);
}

function requestHttpServiceClassProject() {
    // body...
    var resultView = document.getElementById("requestResultShowView");
    resultView.innerHTML = "事件处理中，请稍后";

    var request = new XMLHttpRequest();
    request.setTimeout = 3000;

    var readyState = "readyState:&nbsp;";
    request.onreadystatechange = function () {
        // body...
        readyState += request.readyState + "&nbsp;";
        var str = "<span style='color:red'>" + readyState + "</span><br/>"
        str += request.status + "<br/>";

        if (request.readyState == 4 && request.responseText.length > 0){
            var jsonObject = JSON.parse(request.responseText);
            refreshView(jsonObject)
        }

        resultView.innerHTML = str;
    }
    request.open("GET", "https://as-vip-staging.missfresh.cn/web20/classify/firstClassify/?platform=android&android_channel_value=mryx&session=android862124033532347&tdk=eyJvcyI6ImFuZHJvaWQiLCJ2ZXJzaW9uIjoiMy4wLjkiLCJwYWNrYWdlcyI6ImNuLm1pc3NmcmVzaC5hcHBsaWNhdGlvbl82LjMuMCIsInByb2ZpbGVfdGltZSI6NTM5NiwiaW50ZXJ2YWxfdGltZSI6MTQzNDYsInRva2VuX2lkIjoidVhUMU9oRWU5djl0eEJRWFhieGw1Q2kzRWJ5SlVXQzllbStHQVZvME1GZzR0VDRcL3lBTXlYSFByVzlnXC95dStneEt1dlpcL214aU9qb2pjQnQxV1JRNnc9PSJ9&access_token=LzB3WktvcDVjZ0NiYUEra3EzT0QreGdwek94MVRKbUg1TUNFTG52WXE3MD0=&imei=d9201077206ab88d2133e9df97f60be5&version=6.3.0");
    request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    request.setRequestHeader('x-region', '{"address_code":"110105","station_code":"MRYX|mryx_wj"}');
    request.send(null);

}

function refreshView(jsonObject) {
    console.log(jsonObject);
    console.log(jsonObject.code);
    console.log(jsonObject.success);

    var classifyList = jsonObject.classify_list;
    if (classifyList.length != 0) {
        console.log("请求回来的分类数据不为空");

        var arrayLength = classifyList.length;

        var netArrayContentShow = document.getElementById("netArrayContentShow");
        for (var i = 0; i < arrayLength; i++){
            var person = classifyList[i];

            var div = window.document.createElement("button");
            var attri = document.createAttribute("style");
            attri.nodeValue = "color:#ff4891;padding:10px;border-style:solid;border-width:1px;border-color:#ff491;margin-left:5px;margin-right:5px;";
            div.setAttributeNode(attri);
            div.setAttribute("onclick","nodeClickEvent()");
            var textNode = window.document.createTextNode(person["classify_name"]);
            div.appendChild(textNode);
            netArrayContentShow.appendChild(div);
        }
    }
}

function nodeClickEvent() {
    alert("This button has clicked!");
}
